/*
 * The MIT License (MIT)
 *
 * FXGL - JavaFX Game Library
 *
 * Copyright (c) 2015-2016 AlmasB (almaslvl@gmail.com)
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

package com.windea.study.fxgl.tankwar

import com.almasb.fxgl.dsl.*
import com.almasb.fxgl.dsl.components.*
import com.almasb.fxgl.entity.*
import com.almasb.fxgl.entity.components.*
import com.windea.study.fxgl.tankwar.Config.BULLET_SPEED

/**
 * @author Almas Baimagambetov (AlmasB) (almaslvl@gmail.com)
 */
class BattleTanksFactory : EntityFactory {
	@Spawns("Bullet")
	fun newBullet(data: SpawnData): Entity {
		return entityBuilder()
			.from(data)
			.type(BattleTanksType.BULLET)
			//.bbox(new HitBox("BODY", new Point2D(34, 34), BoundingShape.box(16, 16)))
			.viewWithBBox("tank_bullet.png")
			.with(CollidableComponent(true))
			.with(OffscreenCleanComponent(), ProjectileComponent(data.get("direction"), BULLET_SPEED))
			.build()
	}
	
	@Spawns("F,Flag")
	fun newFlag(data: SpawnData): Entity {
		return entityBuilder()
			.from(data)
			.type(BattleTanksType.FLAG)
			.viewWithBBox("flag.png")
			.with(CollidableComponent(true))
			.build()
	}
	
	@Spawns("1,Wall")
	fun newWall(data: SpawnData): Entity {
		return entityBuilder()
			.from(data)
			.type(BattleTanksType.WALL)
			.viewWithBBox("wall.png")
			.with(CollidableComponent(true))
			.build()
	}
}
